package smetana.modules.ui.actions;

import com.google.inject.Inject;
import org.apache.pivot.wtk.Dialog;
import org.apache.pivot.wtk.DialogCloseListener;
import smetana.modules.ui.form.io.ImportFromDbfPanel;
import smetana.modules.ui.model.UIModel;

/**
 * @author dmitry.mamonov
 */
public class ImportFromDbfAction extends AbstractAction {
    @Inject
    ImportFromDbfPanel importFromDbfPanel;

    @Inject
    UIModel uiModel;

    @Override
    public void perform() {
        final Dialog dialog = new Dialog();
        dialog.setPreferredWidth((int) (uiModel.getWindow().getWidth() * 0.9));
        dialog.setPreferredHeight((int) (uiModel.getWindow().getHeight() * 0.9));
        dialog.setContent(importFromDbfPanel.getComponent());
        dialog.open(uiModel.getWindow().getDisplay(),
                uiModel.getWindow(),
                false,
                new DialogCloseListener() {
                    @Override
                    public void dialogClosed(Dialog dialog, boolean modal) {
                        dialog.setContent(null);
                    }
                });
    }
}